package com.mxpio.erp.common.equipment.service;

import com.mxpio.erp.common.equipment.vo.EquipmentReportVO;
import com.mxpioframework.security.entity.Dept;
import org.springframework.transaction.annotation.Transactional;

import java.math.BigDecimal;
import java.util.List;
import java.util.Map;


/**
 * 汇总报表Service接口
 *
 * @author Cheng
 * @date 2023-08-22
 */
public interface EquipmentReportService {

    /**维修工时统计*/
    List<EquipmentReportVO> getMaintenanceHours();

    /**保养工时统计*/
    List<EquipmentReportVO> getUpkeepHours();

    /**保养计划达成率*/
    List<EquipmentReportVO> getUpkeepCompletionRate();

    /**点检计划达成率*/
    List<EquipmentReportVO> getCheckCompletionRate();

    /**稽核工单达成率*/
    List<EquipmentReportVO> getAuditCompletionRate();

    /**维修工单达成率*/
    List<EquipmentReportVO> getRepairCompletionRate();

    /**设备故障统计报表*/
    List<EquipmentReportVO> getEquipmentFailure();

    /**设备状态看板*/
    List<EquipmentReportVO> getEquipmentStatus();

    /**设备完好率*/
    List<EquipmentReportVO> getEquipmentNormalStatus();

    /**设备故障次数统计*/
    List<EquipmentReportVO> getEquipmentFailureCount();

    /**平均故障前时间MTBF*/
    List<EquipmentReportVO> getMeanTimeBeforeFailure();

    /**平均修复时间MTTR*/
    List<EquipmentReportVO> getMeanTimeToRepair();



    Integer getAssemble() throws Exception;

    Integer getAllocation() throws Exception;

    Integer getToBeRepaired() throws Exception;

    Integer getInMaintenance() throws Exception;

    Integer getSpareParts() throws Exception;

    Integer getOutsourcing() throws Exception;

    Integer getToBeSubmitted() throws Exception;

    Integer getToBeAccepted() throws Exception;

    Integer getToBeEvaluated() throws Exception;

    Integer getOrderStatusAssemble() throws Exception;

    Integer getOrderStatusAllocation() throws Exception;

    Integer getOrderStatusMaintenance() throws Exception;

    Integer getOrderStatusUnderMaintenance() throws Exception;

    Integer getOrderStatusSpareParts() throws Exception;

    Integer getOrderStatusShelve() throws Exception;

    Integer getOrderStatusToBeSubmitted() throws Exception;

    Integer getOrderStatusToBeAccepted() throws Exception;

    Integer getOrderStatusToBeEvaluate() throws Exception;

    /**
     * 设备总数
     * @return
     * @throws Exception
     */
    Integer getEquipmentNum()throws Exception;

    /**
     * 当月故障设备数
     * @return
     * @throws Exception
     */
    Integer getBadEquipmentNum()throws Exception;

    /**
     *  平均修理时间MTTR
     * @return
     * @throws Exception
     */
    BigDecimal getMTTR()throws Exception;

    /**
     *  平均修复时间MTBF
     * @return
     * @throws Exception
     */
    BigDecimal getMTBF() throws Exception;

    /**
     * 设备完好率
     * @return
     * @throws Exception
     */
    BigDecimal getEquGood() throws Exception;

    /**
     *  平均响应时间
     * @return
     * @throws Exception
     */
    String getAverageResponseTime() throws Exception;

    /**
     *   平均维修时间
     * @return
     * @throws Exception
     */
    String getAverageMaintenanceTime() throws Exception;

    /**
     *    平均故障时间
     * @return
     * @throws Exception
     */
    String getAverageDownTime()throws Exception;

    /**
     *   PM计划数
     * @return
     */
    Integer getPMPlanNum()throws Exception;

    /**
     *    PM实际数
     * @return
     * @throws Exception
     */
    Integer getPMActualNum() throws Exception;

    /**
     * 定期维护计划数
     * @return
     * @throws Exception
     */
    Integer getNormp() throws Exception;

    /**
     * 定期维护实际数
     * @return
     * @throws Exception
     */
    Integer getNorma() throws Exception;

    /**
     * PM完成率
     * @return
     * @throws Exception
     */
    String getPMCom() throws Exception;

    /**
     *  定期维护完成率
     * @return
     * @throws Exception
     */
    String getNormCom() throws Exception;

    /**
     * 按时完成率
     * @return
     * @throws Exception
     */
    String getOnTimeCom() throws Exception;

    /**
     * 当月故障趋势
     * @return
     */
    List<EquipmentReportVO> getFaultTrend() throws Exception;

    Map<String, Integer> getMaintenanceDetails();

    Map<String, Integer> getRepairDetails();

//    /**
//     * 获取前30天的类型为CI的停机时长
//     * @return
//     */
//    Result<?> getDowntime();

    /**
     * 一级工段
     * @param code
     * @return
     */
    @Transactional
    String getFirstLevelCode(String code);

    /**
     * 二级工段
     * @param firstUseDeptId
     * @param
     * @return
     */
    @Transactional
    String getSecondLevelCode(String firstUseDeptId, String useDeptId);

    /**
     * 三级工段
     * @param secondUseDeptId
     * @param
     * @return
     */
    @Transactional
    String getThirdLevelCode(String secondUseDeptId, String useDeptId);

    Dept getWithBranchByCode(String code);

    /**
     * 查询当前工段下的所有的子工段
     * @param firstLevelCode
     * @return
     */
    List<String> getChildrenDept(String firstLevelCode);
}
